<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>emit传值，小写变大写</title>
</head>

<body>
    <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
    <div id="Application">
        <child @custom-change="add"></child>
        <p> 您输入的字符大写：{{count}}</p>

    </div>
    <script>
        const App = Vue.createApp({
            setup() {
                const count = Vue.ref("")
                const add = (i) => {
                    count.value = i
                    //接收传来的值
                }
                return {
                    count,
                    add
                }
            },
        });

        //子组件
        const childBlock = {
            setup(props, { emit }) {
                const handleChange = (event) => {
                    emit("customChange", event.target.value.toUpperCase())
                    //自定义触发事件，传出值
                }
                return {
                    handleChange
                }

            },

            template: ' <input type="text" placeholder="请输入字符" @input="handleChange" />'
        }
        App.component("child", childBlock);

        //挂载
        App.mount("#Application");
    </script>
</body>

</html>